import React from 'react';

export default class GridRow extends React.Component {
    getValByKey(key,obj){
        var res = obj[key];
        var a = parseFloat(res);
        if(isNaN(a)){
            return res || "";
        }
        return res;
    };

    render(){
        var param = this.props.param;
        var data = this.props.data;
        var rowIndex = this.props.index;
        var trid = "_tr_" + rowIndex;
        return <tr id={trid}>
            {
                param.map((item,index)=>{
                    var val = this.getValByKey(item.name,data);
                    var showTitle = item.showTitle || true;
                    var tdid = "_td_" + rowIndex + "_" + index;
                    var titleStr = showTitle ? val : "";
                    return <td key={index} id={tdid} title={titleStr}>{val}</td>
                })
            }
        </tr>
    }
}